function Customer(jsonObject) {
	this.internalObject = jsonObject;
}

Customer.prototype = {
	getAddress: function() { return this.internalObject.Address; },
	setAddress: function(address) { this.internalObject.Address = address; },
	getCity: function() { return this.internalObject.City; },
	setCity: function(city) { this.internalObject.City = city; },
	getCompanyName: function() { return this.internalObject.CompanyName; },
	setCompanyName: function(companyname) { this.internalObject.CompanyName = companyname; },
	getContactName: function() { return this.internalObject.ContactName; },
	setContactName: function(contactname) { this.internalObject.ContactName = contactname; },
	getContactTitle: function() { return this.internalObject.ContactTitle; },
	setContactTitle: function(contacttitle) { this.internalObject.ContactTitle = contacttitle; },
	getCountry: function() { return this.internalObject.Country; },
	setCountry: function(country) { this.internalObject.Country = country; },
	getCustomerId: function() { return this.internalObject.CustomerId; },
	getFax: function() { return this.internalObject.Fax; },
	setFax: function(fax) { this.internalObject.Fax = fax; },
	getPhone: function() { return this.internalObject.Phone; },
	setPhone: function(phone) { this.internalObject.Phone = phone; },
	getPostalCode: function() { return this.internalObject.PostalCode; },
	setPostalCode: function(postalcode) { this.internalObject.PostalCode = postalcode; },
	getRegion: function() { return this.internalObject.Region; },
	setRegion: function(region) { this.internalObject.Region = region; },
	getCreatedDate: function() { return this.internalObject.CreatedDate; },
	getCreatedBy: function() { return this.internalObject.CreatedBy; },
	getModifiedDate: function() { return this.internalObject.ModifiedDate; },
	getModifiedBy: function() { return this.internalObject.ModifiedBy; },
	getCustomerObject: function() { return this.internalObject; }
};

function CustomerService() {
}

CustomerService.prototype.retrieveAll = function(successCallback) {
    viewServiceProxy.invokeGet("CustomerList", successCallback, OnPageError, true);
};

CustomerService.prototype.retrievePaged = function(successCallback, pageIndex, pageSize, sortOrder, sortColumn, linq) {
    var restUrl = "CustomerListPage";
    restUrl = restUrl + "/?";

    if (!IsNullOrEmpty(pageIndex)) {
        restUrl = restUrl + "pageIndex=" + pageIndex;
        if (!IsNullOrEmpty(pageSize) || !IsNullOrEmpty(sortOrder) || !IsNullOrEmpty(sortColumn) || !IsNullOrEmpty(linq)) {
            restUrl = restUrl + "&";
        }
    }
    if (!IsNullOrEmpty(pageSize)) {
        restUrl = restUrl + "pageSize=" + pageSize;
        if (!IsNullOrEmpty(sortOrder) || !IsNullOrEmpty(sortColumn) || !IsNullOrEmpty(linq)) {
            restUrl = restUrl + "&";
        }
    }
    if (!IsNullOrEmpty(sortOrder)) {
        restUrl = restUrl + "sortOrder=" + sortOrder;
        if (!IsNullOrEmpty(sortColumn) || !IsNullOrEmpty(linq)) {
            restUrl = restUrl + "&";
        }
    }
    if (!IsNullOrEmpty(sortColumn)) {
        restUrl = restUrl + "sortColumn=" + sortColumn;
        if (!IsNullOrEmpty(linq)) {
            restUrl = restUrl + "&";
        }
    }
    restUrl = restUrl + "linq=" + linq;

    viewServiceProxy.invokeGet(restUrl, successCallback, OnPageError, true);
};

CustomerService.prototype.save = function(customer, successCallback) {
viewServiceProxy.invokePut("Customer", customer.getCustomerObject(), successCallback, OnPageError, true);
};
